package com.davidk.survey.client.dataviewer;

import com.davidk.survey.client.datasource.SurveyDataSource;
import com.davidk.survey.client.datasource.UserDataSource;
import com.davidk.survey.client.eventbus.MasterEventBus;
import com.google.inject.Inject;
import com.mvp4g.client.annotation.Presenter;
import com.mvp4g.client.presenter.BasePresenter;

@Presenter(view = DataView.class)
public class DataPresenter extends BasePresenter<DataViewInterface, MasterEventBus> {
	
	SurveyDataSource surveyDs;
	UserDataSource userDs;
	
	public UserDataSource getUserDs() {
		return userDs;
	}

	@Inject
	public void setUserDs(UserDataSource userDs) {
		this.userDs = userDs;
	}

	public SurveyDataSource getSurveyDs() {
		return surveyDs;
	}

	@Inject
	public void setSurveyDs(SurveyDataSource surveyDs) {
		this.surveyDs = surveyDs;
	}

	public void onStart() {
	}

	public void onShowFunction(String fnType, String fnData) {
		if (fnType.equals("fn") && fnData.equals("survey")){
			eventBus.changeBody(view.getView(getSurveyDs()));
//			view.setDataSource(getSurveyDs());
		} else if (fnType.equals("fn") && fnData.equals("users")){
			eventBus.changeBody(view.getView(getUserDs()));
//			view.setDataSource(getUserDs());
		}
	}
}
